<template>
  <div class='member-comment-page'>
    <!-- tab组件 -->
    <XtxTabs v-model="activeName" @tab-click="tabClick">
      <XtxTabsPanel v-for="item in commentStatus" :key="item.name" :label="item.label" :name="item.name"></XtxTabsPanel>
    </XtxTabs>
    <!-- 商品列表 -->
    <div class="comment-goods-list">
      <div v-if="loading" class="loading"></div>
      <div class="none" v-if="loading">暂无数据</div>
      <ul>
        <li v-for="item in 8" :key="item">
          <comment-goods :currentType="activeName"></comment-goods>
        </li>
      </ul>
      <!-- 分页组件 -->
      <xtxPagination
        v-if="total > 0"
        :current-page="reqParams.page"
        :page-size="reqParams.pageSize"
        @current-change="reqParams.page=$event"
        :total="total"
      />
      <!-- <comment-goods :currentType="activeName" v-for="item in EvaluateList" :key="item.id" :order="item"></comment-goods> -->
    </div>
  </div>
</template>

<script>
import { orderStatus, commentStatus } from '@/api/constant'
import CommentGoods from './components/comment-goods.vue'
import { reactive, ref, watch } from 'vue'
export default {
  name: 'member-comment-page',
  components: {
    CommentGoods
  },
  setup () {
    const activeName = ref('to_comment')
    // 点击选项卡
    const tabClick = ({ index }) => {
      reqParams.page = 1
      reqParams.orderState = index + 4
    }
    // 查询参数
    const reqParams = reactive({
      page: 1,
      pageSize: 5,
      orderState: 4
    })
    // 获取评价订单商品列表
    const loading = ref(false)
    // 分页数据总条数
    const total = ref(0)
    const getGoodsList = () => {
    }
    // 切换分页时发生变化就重新加载数据
    watch(reqParams, () => {
      getGoodsList()
    }, { immediate: true })
    return { activeName, orderStatus, commentStatus, tabClick, total, loading, reqParams }
  }
}
</script>

<style scoped lang='less'>
.member-comment-page {
  height: 100%;
  background: #fff;
}
.comment-goods-list {
  // display: flex;
  // padding: 20px 50px 0;
  // flex-wrap: wrap;
  padding: 20px;
  min-height: 400px;
  position: relative;
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 216px;
      height: 341px;
      text-align: center;
      padding: 20px 30px;
      position: relative;
      margin-right: 30px;
      margin-bottom: 20px;
      &:nth-child(4n) {
        margin-right: 0;
      }
      &:hover {
        transition: all .5s;
        box-shadow: 0 3px 8px rgba(0,0,0,0.2);
      }
    }
  }
  .loading {
    height: 100%;
    width: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(255,255,255,.9) url(../../../assets/images/loading.gif) no-repeat center;
  }
  .none {
    height: 400px;
    text-align: center;
    line-height: 400px;
    color: #999;
    margin: 0 auto;
  }
}
</style>
